<?php

namespace App\Models;

use     App\Exceptions\ApiExceptions;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class SignUpJobpositionModel extends AbstractBaseModel
{
    use SoftDeletes;


    protected $table = 'sign_up_job_position';

    protected $casts = [
        'tags' => 'json',
    ];

    // 定义多对多关系
    public function categories()
    {
        return $this->belongsToMany(CategoryModel::class, jobPositionCategoryModel::class, 'job_position_id', 'category_id')
            ->withTimestamps();
    }
    /**
     * 职位信息
     * @return HasOne
     */
    public function jobPositionInfo(): HasOne
    {
        return $this->HasOne(JobpositionModel::class, 'id', 'job_position_id');
    }
    /**
     * 关联模式
     * @return BelongsTo
     */
    public function company()
    {
        return $this->belongsTo(CompanyModel::class, 'company_id');
    }
    /**
     * 用户信息
     * @return BelongsTo
     */
    public function userInfo(): BelongsTo
    {
        return $this->belongsTo(User::class, 'user_id')->withTrashed();
    }

}
